package operator;

/**
 * @author shkstart
 * @date 2022/3/30 - 22:18
 */
public class SelfIncreasingAndSelfDecreasing {
    public static void main(String[] args) {
//       前++：先自增1再赋值
//       后++：先赋值再自增1
        int a1 = 12;
        int b1 = ++a1;
        System.out.println("a1 = " + a1 + ",b1 = " + b1);

        int a2 = 12;
        int b2 = a1++;
        System.out.println("a2 = " + a2 + ",b2 = " + b2);

        int a3 = 10;
        ++a3; // a3++
        int b3 = a3;

//        注意：
            short s1 = 12;
//            s1 =  s1 + 1; //编译失败
//            s1 = (short)(s1 + 1);//正确的
                s1++;//自增1不会改变变量本身数据类型！
        System.out.println("s1 = " + s1);

//        问题：
        byte bb1 = 127;
        bb1++;
        System.out.println("bb1 = " + bb1);

//       前--
//       后--

        int a4 = 10;
        int b4 = a4--;
        System.out.println("a4 = " + a4 + ",b4 = " + b4);


    }
}
